Class ADORecordSet

Description

RecordSet class that represents the dataset returned by the database.

To keep memory overhead low, this class holds only the current row in memory. No prefetching of data is done, so the RecordCount() can return -1 ( which means recordcount not known).

Located in /adodb/adodb.inc.php (line 1273)


	
			
Direct descendents
Class Description
RecordSet class that represents the dataset returned by the database.
RecordSet class that represents the dataset returned by the database.
ADORecordSet_array This class encapsulates the concept of a recordset created in memory as an array. This is useful for the creation of cached recordsets.
ADORecordSet_odbc RecordSet class that represents the dataset returned by the database.
Variable Summary
mixed $bind
mixed $blobSize
mixed $canSeek
mixed $connection
mixed $debug
mixed $emptyDate
mixed $EOF
mixed $fetchMode
mixed $fields
mixed $sql
mixed $timeCreated
mixed $_atLastPage
mixed $_closed
mixed $_currentRow
mixed $_inited
mixed $_names
mixed $_numOfRows
mixed $_obj
mixed $_queryID
Method Summary
ADORecordSet ADORecordSet (queryID &$queryID)
void AbsolutePage ([mixed $page = -1])
void AtFirstPage ([mixed $status = false])
void AtLastPage ([mixed $status = false])
true Close ()
the CurrentRow ()
the &FetchField (fieldoffset $fieldoffset)
DB_OK FetchInto (mixed &$arr)
the &FetchNextObject ([$isupper $isupper = true])
the &FetchObject ([$isupper $isupper = true])
false FetchRow ()
the FieldCount ()
the Fields (colname $colname)
void Free ()
an GetArray ([[nRows] $nRows = -1])
an GetArrayLimit (offset $nrows, [[nrows] $offset = -1])
an GetAssoc ([[force_array] $force_array = false])
HTML GetMenu (name $name, [[defstr] $defstr = ''], [[blank1stItem] $blank1stItem = true], [[multiple] $multiple = false], [size] $size, [[selectAttr] $selectAttr = ''], [mixed $compareFields0 = true])
void GetMenu2 (mixed $name, [mixed $defstr = ''], [mixed $blank1stItem = true], [mixed $multiple = false], mixed $size, [mixed $selectAttr = ''])
void &GetRowAssoc ([mixed $upper = true])
an GetRows ([[nRows] $nRows = -1])
void Init ()
the MetaType (t $t, [len $len = -1], [fieldobj $fieldobj = false])
true Move (rowNumber $rowNumber)
true MoveFirst ()
true MoveLast ()
true MoveNext ()
void NextRecordSet ()
void NumCols ()
void NumRows ()
the PO_RecordCount ([mixed $table = ""], [mixed $condition = ""])
the RecordCount ()
the RowCount ()
date UnixDate ($v $v)
date UnixTimeStamp ($v $v)
a UserDate (v $v, [fmt $fmt = 'Y-m-d'])
a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'])
void _close ()
Variables
mixed $bind = false (line 1290)

Redefined in descendants as:
mixed $blobSize = 64 (line 1279)
mixed $canSeek = false (line 1281)

Redefined in descendants as:
mixed $connection = false (line 1292)
mixed $dataProvider = "native" (line 1277)

Redefined in descendants as:
mixed $debug = false (line 1287)
mixed $emptyDate = ' ' (line 1286)
mixed $emptyTimeStamp = ' ' (line 1285)
mixed $EOF = false (line 1283)
mixed $fetchMode (line 1291)
mixed $fields = false (line 1278)
mixed $sql (line 1282)

Redefined in descendants as:
mixed $timeCreated (line 1288)
mixed $_atFirstPage = false (line 1306)
mixed $_atLastPage = false (line 1307)
mixed $_closed = false (line 1300)
mixed $_currentPage = -1 (line 1305)
mixed $_currentRow = -1 (line 1299)
mixed $_inited = false (line 1301)
mixed $_names (line 1303)
mixed $_numOfFields = -1 (line 1297)
mixed $_numOfRows = -1 (line 1296)
mixed $_obj (line 1302)
mixed $_queryID = -1 (line 1298)
Methods
Constructor ADORecordSet (line 1316)

Constructor

ADORecordSet ADORecordSet (queryID &$queryID)
  • queryID &$queryID: this is the queryID returned by ADOConnection->_query()
AbsolutePage (line 1986)

set/returns the current recordset page when paginating

void AbsolutePage ([mixed $page = -1])
AbsolutePosition (line 1820)

synonym for CurrentRow -- for ADO compat

  • return: current row in the recordset. If at EOF, will return the last row. 0-based.
the AbsolutePosition ()
AtFirstPage (line 1995)

set/returns the status of the atFirstPage flag when paginating

void AtFirstPage ([mixed $status = false])
AtLastPage (line 2004)

set/returns the status of the atLastPage flag when paginating

void AtLastPage ([mixed $status = false])
Close (line 1760)

Clean up recordset

  • return: or false
true Close ()
CurrentRow (line 1813)
  • return: current row in the recordset. If at EOF, will return the last row. 0-based.
the CurrentRow ()
FetchField (line 1836)

Get the ADOFieldObject of a specific column.

  • return: ADOFieldObject for that column, or false.
the &FetchField (fieldoffset $fieldoffset)
  • fieldoffset $fieldoffset: is the column position to access(0-based).

Redefined in descendants as:
FetchInto (line 1619)

Fetch a row, returning PEAR_Error if no more rows.

This is PEAR DB compat mode.

  • return: or error object
DB_OK FetchInto (mixed &$arr)
FetchNextObject (line 1879)

Return the fields array of the current row as an object for convenience.

  • return:

    object with the properties set to the fields of the current row, or false if EOF

    Fixed bug reported by tim@orotech.net

the &FetchNextObject ([$isupper $isupper = true])
  • $isupper $isupper: to set the object property names to uppercase
FetchObject (line 1848)

Return the fields array of the current row as an object for convenience.

  • return: object with the properties set to the fields of the current row
the &FetchObject ([$isupper $isupper = true])
  • $isupper $isupper: to set the object property names to uppercase
FetchRow (line 1604)

Fetch a row, returning false if no more rows.

This is PEAR DB compat mode.

  • return: or array containing the current record
false FetchRow ()
FieldCount (line 1826)
  • return: number of columns in the recordset. Some databases will set this to 0 if no records are returned, others will return the number of columns in the query.
the FieldCount ()
Fields (line 1722)

Get the value of a field in the current row by column name.

Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM.

  • return: value of $colname column
the Fields (colname $colname)
  • colname $colname: is the field to access

Redefined in descendants as:
Free (line 1575)

PEAR DB Compat - do not use internally

void Free ()
GetArray (line 1390)

return recordset as a 2-dimensional array.

  • return: array indexed by the rows (0-based) from the recordset
an GetArray ([[nRows] $nRows = -1])
  • [nRows] $nRows: is the number of rows to return. -1 means every row.
GetArrayLimit (line 1420)

return recordset as a 2-dimensional array.

Helper function for ADOConnection->SelectLimit()

  • return: array indexed by the rows (0-based) from the recordset
an GetArrayLimit (offset $nrows, [[nrows] $offset = -1])
  • offset $nrows: is the row to start calculations from (1-based)
  • [nrows] $offset: is the number of rows to return
GetAssoc (line 1461)

return whole recordset as a 2-dimensional associative array if there are more than 2 columns.

The first column is treated as the key and is not included in the array. If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless $force_array == true.

  • return: associative array indexed by the first column of the array, or false if the data has less than 2 cols.
an GetAssoc ([[force_array] $force_array = false])
  • [force_array] $force_array: has only meaning if we have 2 data columns. If false, a 1 dimensional array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, read the source.
GetMenu (line 1360)

Generate a <SELECT> string from a recordset, and return the string.

If the recordset has 2 cols, we treat the 1st col as the containing the text to display to the user, and 2nd col as the return value. Default strings are compared with the FIRST column.

  • return: changes by glen.davies@cce.ac.nz to support multiple hilited items
HTML GetMenu (name $name, [[defstr] $defstr = ''], [[blank1stItem] $blank1stItem = true], [[multiple] $multiple = false], [size] $size, [[selectAttr] $selectAttr = ''], [mixed $compareFields0 = true])
  • name $name: name of <SELECT>
  • [defstr] $defstr: the value to hilite. Use an array for multiple hilites for listbox.
  • [blank1stItem] $blank1stItem: true to leave the 1st item in list empty
  • [multiple] $multiple: true for listbox, false for popup
  • [size] $size: #rows to show for listbox. not used by popup
  • [selectAttr] $selectAttr: additional attributes to defined for <SELECT>. useful for holding javascript onChange='...' handlers. column 0 (1st col) if this is true. This is not documented.
GetMenu2 (line 1375)

Generate a <SELECT> string from a recordset, and return the string.

If the recordset has 2 cols, we treat the 1st col as the containing the text to display to the user, and 2nd col as the return value. Default strings are compared with the SECOND column.

void GetMenu2 (mixed $name, [mixed $defstr = ''], [mixed $blank1stItem = true], [mixed $multiple = false], mixed $size, [mixed $selectAttr = ''])
GetRowAssoc (line 1735)

Use associative array to get fields array for databases that do not support associative arrays. Submitted by Paolo S. Asioli paolo.asioli@libero.it

If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC before you execute your SQL statement, and access $rs->fields['col'] directly.

void &GetRowAssoc ([mixed $upper = true])

Redefined in descendants as:
GetRows (line 1443)

Synonym for GetArray() for compatibility with ADO.

  • return: array indexed by the rows (0-based) from the recordset
an GetRows ([[nRows] $nRows = -1])
  • [nRows] $nRows: is the number of rows to return. -1 means every row.
Init (line 1322)
void Init ()
MetaType (line 1915)

Get the metatype of the column. This is used for formatting. This is because many databases use different names for the same type, so we transform the original type to our standardised version which uses 1 character codes:

  • return: general type of the data: C for character < 200 chars X for teXt (>= 200 chars) B for Binary N for numeric floating point D for date T for timestamp L for logical/Boolean I for integer R for autoincrement counter/integer
the MetaType (t $t, [len $len = -1], [fieldobj $fieldobj = false])
  • t $t: is the type passed in. Normally is ADOFieldObject->type.
  • len $len: is the maximum length of that field. This is because we treat character fields bigger than a certain size as a 'B' (blob).
  • fieldobj $fieldobj: is the field object returned by the database driver. Can hold additional info (eg. primary_key for mysql).

Redefined in descendants as:
Move (line 1683)

Random access to a specific row in the recordset. Some databases do not support access to previous rows in the databases (no scrolling backwards).

  • return: if there still rows available, or false if there are no more rows (EOF).
true Move (rowNumber $rowNumber)
  • rowNumber $rowNumber: is the row to move to (0-based)
MoveFirst (line 1633)

Move to the first row in the recordset. Many databases do NOT support this.

  • return: or false
true MoveFirst ()
MoveLast (line 1645)

Move to the last row in the recordset.

  • return: or false
true MoveLast ()
MoveNext (line 1658)

Move to next record in the recordset.

  • return: if there still rows available, or false if there are no more rows (EOF).
true MoveNext ()

Redefined in descendants as:
NextRecordSet (line 1406)
void NextRecordSet ()
NumCols (line 1593)

PEAR DB compat, number of cols

void NumCols ()
NumRows (line 1584)

PEAR DB compat, number of rows

void NumRows ()
PO_RecordCount (line 1796)

Portable RecordCount. Pablo Roca <pabloroca@mvps.org>

  • return:

    number of records from a previous SELECT. All databases support this.

    But aware possible problems in multiuser environments. For better speed the table must be indexed by the condition. Heavy test this before deploying.

the PO_RecordCount ([mixed $table = ""], [mixed $condition = ""])
RecordCount (line 1777)

synonyms RecordCount and RowCount

  • return: number of rows or -1 if this is not supported
the RecordCount ()
RowCount (line 1785)

synonyms RecordCount and RowCount

  • return: number of rows or -1 if this is not supported
the RowCount ()
UnixDate (line 1544)
  • return: in unix timestamp format, or 0 if before 1970, or false if invalid date format
date UnixDate ($v $v)
  • $v $v: is a date string in YYYY-MM-DD format
UnixTimeStamp (line 1560)
  • return: in unix timestamp format, or 0 if before 1970, or false if invalid date format
date UnixTimeStamp ($v $v)
  • $v $v: is a timestamp string in YYYY-MM-DD HH-NN-SS format
UserDate (line 1526)
  • return: date formated as user desires
a UserDate (v $v, [fmt $fmt = 'Y-m-d'])
  • v $v: is the character date in YYYY-MM-DD format
  • fmt $fmt: is the format to apply to it, using date()
UserTimeStamp (line 1509)
  • return: timestamp formated as user desires
a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'])
  • v $v: is the character timestamp in YYYY-MM-DD hh:mm:ss format
  • fmt $fmt: is the format to apply to it, using date()

Documentation generated on Thu, 04 Sep 2008 16:14:47 +0400 by phpDocumentor 1.3.0RC3